#include <iostream>
using namespace std;

long long sequence[5843];
int main()
{
    sequence[0] = -1;
    sequence[1] = 1;
    int a2=1, a3=1, a5=1, a7=1, i=2, n;
    for(i=2; i<5843; i++)
    {
        sequence[i] = min(sequence[a7]*7, min(sequence[a5]*5, min(sequence[a2]*2, sequence[a3] * 3)));
        if(sequence[i] == sequence[a2]*2)
        {
            a2 ++;
        }
        if(sequence[i] == sequence[a3]*3)
        {
            a3 ++;
        }
        if(sequence[i] == sequence[a5]*5)
        {
            a5 ++;
        }
        if(sequence[i] == sequence[a7] * 7)
        {
            a7 ++;
        }
    }
    while(cin >> n)
    {
        if(n==0)
        {
            break;
        }
        if(n % 10 == 1 && n % 100 != 11)
        {
            cout << "The " << n << "st humble number is " << sequence[n] << "." << endl;
        }
        else if(n % 10 == 2 && n % 100 != 12)
        {
            cout << "The " << n << "nd humble number is " << sequence[n] << "." << endl;
        }
        else if(n%10 == 3 && n % 100 != 13)
        {
            cout << "The " << n << "rd humble number is " << sequence[n] << "." << endl;
        }
        else
        {
            cout << "The " << n << "th humble number is " << sequence[n] << "." << endl;
        }
    }
    return 0;
}